package com.zhuoyue.biz.core.api.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zhuoyue.biz.core.api.domain.base.BaseDoClass;

import java.io.Serializable;

import com.zhuoyue.biz.core.api.dto.req.GeofencingReqDTO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @ClassName: Geofencing
 * @Description: 地理围栏
 * @author wjming
 * @Date 2021-07-08 13:21
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "`tbl_geofencing`")
public class Geofencing extends BaseDoClass implements Serializable {
    /**
     * 网关ID
     */
    @TableField(value = "`gateway_id`")
    private String gatewayId;

    /**
     * 执行名称
     */
    @TableField(value = "`name`")
    private String name;

    /**
     * 场景ID
     */
    @TableField(value = "`scene_id`")
    private String sceneId;

    /**
     * 离家距离
     */
    @TableField(value = "`distance`")
    private Double distance;

    /**
     * 使能判断
     */
    @TableField(value = "`enable`")
    private Boolean enable;

    /**
     * 时间周期周一到周日
     */
    @TableField(value = "`time`")
    private String time;

    /**
     * 0:圈内，1圈外
     */
    @TableField(value = "`type`")
    private String type;

    private static final long serialVersionUID = 1L;

    /**
     * 地理围栏信息转化reqDTO转化为数据层
     *
     * @param reqDto
     * @return
     */
    public Geofencing reqDtoToGeofencing(GeofencingReqDTO reqDto) {
        setId(reqDto.getId());
        this.gatewayId = reqDto.getGatewayId();
        this.name = reqDto.getName();
        this.sceneId = reqDto.getSceneId();
        this.distance = reqDto.getDistance();
        this.enable = reqDto.getEnable();
        this.time = reqDto.getTime();
        this.type = reqDto.getType();
        return this;
    }
}